<template>
  <div class="container">
    <div class="main">
      <div class="contact flex-box">
        <div class="border"></div>
        <div>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-gb-duihua1"></use>
          </svg>
          <p>联系客服</p>
        </div>
      </div>
      <div class="cart flex-box">
        <div @click="toCart">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-gb-gouwuche"></use>
          </svg>
          <span class="norem" v-if="cartNum">{{cartNum}}</span>
          <p>购物车</p>
        </div>
      </div>
      <button class="add-cart flex-box" v-if="carBtnState!==0" :disabled="carBtnState===1" @click="showCart">
        加入购物车
      </button>
      <button class="buy-now flex-box" :class="{'jifen-active':carBtnState===0}" :disabled="!buyBtnState" @click="showBrought">
        {{buyBtnVal}}
      </button>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import '@/assets/css/gb-index.scss'
import '@/assets/js/app/iconfont-gb'
// @ is an alias to /src
export default {
  name: 'proFooter',
  data() {
    return {
      lists: ''
    }
  },
  components: {},
  computed: {
    ...mapGetters({
      cartNum: 'cart/cartNum'
    })
  },
  props: ['carBtnState', 'buyBtnState', 'buyBtnVal'],
  methods: {
    toCart() {
      this.$router.push({ name: 'Cart' })
    },
    showCart() {
      this.$bus.$emit('cartBox', true)
    },
    showBrought() {
      this.$bus.$emit('broughtBox', true)
    }
  },
  created() {},
  mounted() {}
}
</script>
<style scoped lang="scss">
.container {
  width: 100%;
  height: 46px;
  position: fixed;
  left: 0;
  bottom: 0;
  background: #fff;
  z-index: 6666;
  color: #999;
  font-size: 20px;
  &::before,
  &::after {
    content: '';
    width: 100%;
    display: block;
    position: absolute;
    left: 0;
    transform: scaleY(0.5);
  }
  &::before {
    top: 0;
    border-top: 1px solid #ccc;
    transform-origin: top left;
  }
  &::after {
    bottom: 0;
    position: relative;
    top: -1px;
    border-bottom: 1px solid #ccc;
    transform-origin: bottom left;
  }
  .main {
    width: 100%;
    height: 100%;
    & > div {
      height: 100%;
      float: left;
      position: relative;
      p {
        font-size: 10px;
        color: #666;
        margin-top: 4px;
      }
    }
    .border {
      height: 100%;
      position: absolute;
      right: 0;
      top: 0;
      transform: scaleX(0.5);
      border-right: 1px solid #ccc;
      transform-origin: top right;
    }
    .contact {
      width: 20%;
    }
    .cart {
      width: 20%;
      & > div {
        position: relative;
      }
      .norem {
        width: 14px;
        height: 14px;
        position: absolute;
        background: #f00;
        text-align: center;
        line-height: 15px;
        font-size: 10px;
        color: #fff;
        top: -2px;
        right: -2px;
        border-radius: 12px;
      }
    }
    .buy-now {
      width: 30%;
      height: 100%;
      color: #fff;
      font-size: 16px;
      background: #ff4242;
      border: none;
      outline: none;
      float: left;
      box-sizing: border-box;
      &.jifen-active {
        width: 60%;
      }
      &:disabled {
        background: #aaa;
      }
    }
    .add-cart {
      width: 30%;
      height: 100%;
      color: #fff;
      font-size: 16px;
      border: none;
      outline: none;
      float: left;
      background: #fe9402;
      &:disabled {
        background: #ccc;
        border-right: 1px solid #fff;
      }
    }
  }
}
</style>
